package com.zzb.controller;


import com.zzb.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 张智博
 * @since 2022-02-22
 */
@Controller
public class UserController {

    @Autowired
    HttpSession session;

    @GetMapping("/getUsername")
    @ResponseBody
    public Map<String, String> getUsername(){
        Map<String, String> map = new HashMap<>();
        User loginUser = (User)session.getAttribute("loginUser");
        map.put("username",loginUser.getUsername());
        map.put("uid",loginUser.getUid());
        return map;
    }

}

